<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
	<title>Become A SunMaxx Solar Thermal Dealer / Installer</title>
	<link rel="stylesheet" type="text/css" href="/wp-content/themes/SunMaxxSolar/style.css" />

<link href="/wp-content/themes/SunMaxxSolar/css/dropdown/dropdown.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/wp-content/themes/SunMaxxSolar/css/dropdown/themes/default/default.css" media="screen" rel="stylesheet" type="text/css" />

<!--[if lt IE 7]>
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/jquery/jquery.dropdown.js"></script>
<![endif]-->

</head>

<body>

<div id="wrapper-top"></div>

<div id="wrapper">

<?php include ('wp-content/themes/SunMaxxSolar/header-no-wp.php'); ?>

	<div id="container">
    
    	<?php include ('wp-content/themes/SunMaxxSolar/sidebar-no-wp.php'); ?>
    
		<div id="content">


<?

require_once("/home/sbbl/www/cgi-bin/hn_captcha.class.php"); 

// sanitize Inputs 

if(isset($_GET) && is_array($_GET)) { 
while(list($key, $value) = each($_GET)) 
    $_GET["$key"] = strip_tags($value); 
} 
if(isset($_POST) && is_array($_POST)) { 
while(list($key, $value) = each($_POST)) 
    $_POST["$key"] = strip_tags($value); 
} 
if(isset($_COOKIES) && is_array($_COOKIES)) { 
while(list($key, $value) = each($_COOKIES)) 
    $_COOKIES["$key"] = strip_tags($value); 
} 


echo "\n";

/////////////////////////////////////////////////////////////////////////////
//Beginning of code edited by Sonny Michaud for saving the form in a database
////////////////////////////////////////////////////////////////////////////
$form_values;
$username;
$host = "207.182.146.162"; $dbuser = "siliconsolar_xca"; $dbpass = "arlingSolar4"; $db = "siliconsolar_xcartdb";
$con = mysql_connect("$host", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$db") or die(mysql_error());

$CAPTCHA_INIT = array( 
    'tempfolder'     => $_SERVER['DOCUMENT_ROOT'].'/_tmp/', 
    'TTF_folder'     => dirname(__FILE__).'/fonts/', 
    'TTF_RANGE'    => 'AUTO', 
    'chars'          => 5,       // integer: number of chars to use for ID 
    'minsize'        => 20,      // integer: minimal size of chars 
    'maxsize'        => 30,      // integer: maximal size of chars 
    'maxrotation'    => 25,      // integer: define the maximal angle for char-rotation, good results are between 0 and 30 
    'use_only_md5'   => FALSE,   // boolean: use chars from 0-9 and A-F, or 0-9 and A-Z 
    'noise'          => TRUE,    // boolean: TRUE = noisy chars | FALSE = grid 
    'websafecolors'  => FALSE,   // boolean 
    'refreshlink'    => TRUE,    // boolean 
    'lang'           => 'en',    // string:  ['en'|'de'|'fr'|'it'|'fi'|'nl'] 
    'maxtry'         => 3,       // integer: [1-9] 
    'badguys_url'    => '/',     // string: URL 
    'secretstring'   => 'choadling is my secret string used to generate the CR4ZY key', 
    'secretposition' => 9        // integer: [1-32] 
);

$captcha =& new hn_captcha($CAPTCHA_INIT);
switch($captcha->validate_submit()) 
    {
    	case 1:

		if (isset($_POST['submit']) && check_form()) send_form();
		break;
	default:
		$countries = mysql_query("SELECT code FROM xcart_countries WHERE active='Y' ORDER BY code");
		$us_states = mysql_query("SELECT state, code FROM xcart_states WHERE country_code='US' ORDER BY state");
		$ca_states = mysql_query("SELECT state, code FROM xcart_states WHERE country_code='CA' ORDER BY state");
		?>
		<script type="text/javascript">
		<!--
			var check_name = "solarexpyes";
			var toggle = new Array("collectortypes_1", "collectortypes_0", "collectortypes_2", "qtydomestic", "qtyheating", "qtypool", "shwexpyrs", "shwpercent");
			var disappear = new Array("star1", "star2", "star3", "star4", "star5", "star6", "star7");
			function check_toggle(value) {
				check = (value == 'no') ? true : false;
				for(i in toggle) document.getElementById(toggle[i]).disabled = check ? true : false;
				for(j in disappear) document.getElementById(disappear[j]).innerHTML = check ? "*" : "&nbsp;";
			}
		
			function check_country() {
				var value = document.getElementById('country').value;
				document.getElementById('stateSelCA').style.display = (value == "CA") ? "inline" : "none";
				document.getElementById('stateSelUS').style.display = (value == "US") ? "inline" : "none";
				document.getElementById('stateText').style.display = (value != "CA" && value != "US") ? "inline" : "none";
		
				document.getElementById('stateSelCA').disabled = (value != "CA") ? true : false;
				document.getElementById('stateSelUS').disabled = (value != "US") ? true : false;
				document.getElementById('stateText').disabled = (value == "US" || value == "CA") ? true : false;
			}
		//-->
		</script>
		<p>
		 Please Fill out this form completely to better help our Dealer Developmnent Team process your application through our system.  Due to heavy interest in the SunMaxx Dealer Network, it may take our representative 1 - 2 business days to contact you. Please be patient.
		</p>
		
		<form name="" method="post" action="">
		 <table width="544" border="0" cellspacing="0" cellpadding="0">
		  <tr>
		   <td width="40%"><font color="#ff0000">*</font><strong>Application Type:</strong></td>
		   <td width="60%">
		    <table width="200">
		     <tr>
		      <td>
		       <input type="radio" name="apptype" value="d" id="RadioGroup1_0"<? if(isset($_POST['apptype']) && $_POST['apptype'] == "d") echo " checked=\"checked\""?> />
		       Dealer and Installer
		      </td>
		     </tr>
		     <tr>
		      <td>
		       <input type="radio" name="apptype" value="i" id="RadioGroup1_1"<?if(isset($_POST['apptype'])  && $_POST['apptype'] == "i") echo " checked=\"checked\""?> />
		       Installer Only
		      </td>
		     </tr>
		    </table>
		   </td>
		  </tr>
		  <tr>
		   <td width="40%"><strong>General Information:</strong></td>
		   <td width="60%">&nbsp;</td>
		  </tr>
		  <tr>
		   <td width="40%"><font color="#ff0000">*</font>First Name:</td>
		   <td width="60%"><input name="firstname" type="text" id="firstname" size="40" value="<? if(isset($_POST['firstname'])){echo $_POST['firstname'];}?>" /></td>
		  </tr>
		  <tr>
		   <td><font color="#ff0000">*</font>Last Name:</td>
		   <td><input name="lastname" type="text" id="lastname" size="40" value="<? if(isset($_POST['lastname'])) {echo $_POST['lastname'];}?>" /></td>
		  </tr>
		  <tr>
		   <td width="40%"><font color="#ff0000">*</font>Company Name (DBA):</td>
		   <td width="60%"><input name="companyname" type="text" id="companyname" size="40" value="<? if(isset($_POST['companyname'])){echo $_POST['companyname']; }?>" /></td>
		  </tr>
		  <tr>
		   <td width="40%"><font color="#ff0000">*</font>Tax ID Number:</td>
		   <td width="60%"><input name="taxid" type="text" id="taxid" size="40" value="<?if(isset($_POST['taxid'])){echo $_POST['taxid'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>Address 1:</td>
		     <td width="60%"><input name="address1" type="text" id="address1" size="40" value="<?if(isset($_POST['address1'])){echo $_POST['address1'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>Address 2:</td>
		     <td width="60%"><input name="address2" type="text" id="address2" size="40" value="<?if(isset($_POST['address2'])){echo $_POST['address2'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>City:</td>
		     <td width="60%"><input name="city" type="text" id="city" size="40" value="<?if(isset($_POST['city'])){echo $_POST['city'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>State:</td>
		     <td width="60%">
		<?
			$show = !isset($_POST['country']) ? "US" : $_POST['country'];
		
			echo "      <select name=\"state\" id=\"stateSelUS\"";
			if ($show != "US") echo " style=\"display: none\" disabled=\"disabled\"";
			echo ">\n";
			while ($row = mysql_fetch_array($us_states)) {
				echo "       <option value=\"".$row['code']."\"";
				if (isset($_POST['state']) && ($row['code'] == $_POST['state'])  ) echo " selected=\"selected\"";
				echo ">".$row['state']."</option>\n";
			}
			echo "      </select>\n";
		
			echo "      <select name=\"state\" id=\"stateSelCA\"";
			if ($show != "CA") echo " style=\"display: none\" disabled=\"disabled\"";
			echo ">\n";
			while ($row = mysql_fetch_array($ca_states)) {
				echo "       <option value=\"".$row['code']."\"";
				if ($row['code'] == $_POST['state']) echo " selected=\"selected\"";
				echo ">".$row['state']."</option>\n";
			}
			echo "      </select>\n";
			echo "      <input name=\"state\" id=\"stateText\" size=\"40\"";
			if ($show == "US" || $show == "CA") echo " style=\"display: none\" disabled=\"disabled\"";
			if ($show != "US" && $show != "CA") echo " value=\"".$_POST['state']."\"";
			echo " />\n";
		?>
		     </td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Country:</td>
		     <td>
		      <select name="country" id="country" onchange="check_country()">
		<? 
			while ($row = mysql_fetch_array($countries)) {
				if ($_POST['country'] == "") {
					echo "       <option value=\"".$row['code']."\"";
					if ($row['code'] == "US") echo " selected=\"selected\"";
					echo ">".$row['code']."</option>\n";
				}
				else {
					echo "       <option value=\"".$row['code']."\"";
					if ($row['code'] == $_POST['country']) echo " selected=\"selected\"";
					echo ">".$row['code']."</option>\n";
				}
			}
		
		?>
		      </select>
		     </td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>Zip Code:</td>
		     <td width="60%"><input name="zip" type="text" id="zip" size="40" value="<? if(isset($_POST['zip'])){echo $_POST['zip'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>Phone Number:</td>
		     <td width="60%"><input name="phone" type="text" id="phone" size="40" value="<? if(isset($_POST['phone'])){echo $_POST['phone'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>Fax Number:</td>
		     <td width="60%"><input name="fax" type="text" id="fax" size="40" value="<? if(isset($_POST['fax'])){echo $_POST['fax'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>Email Address:</td>
		     <td width="60%"><input name="email" type="text" id="email" size="40" value="<? if(isset($_POST['email'])){echo $_POST['email'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%">&nbsp;Website:</td>
		     <td width="60%"><input name="website" type="text" id="website" size="40" value="<? if(isset($_POST['website'])){echo $_POST['website'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><strong>Specific Business Informaton:</strong></td>
		     <td width="60%">&nbsp;</td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>Primary Business Focus:</td>
		     <td width="60%"><input name="primefocus" type="text" id="primfocus" size="40" value="<? if(isset($_POST['primefocus'])){echo $_POST['primefocus'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Number of Years in Business:</td>
		     <td><input name="yrsinbusiness" type="text" id="yrsinbusiness" size="40" value="<?if(isset($_POST['yrsinbusiness'])){echo $_POST['yrsinbusiness'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>Have you ever installed Solar Hot Water Collectors or Systems before?</td>
		     <td width="60%">
		      <table width="200">
		       <tr>
			<td>
			 <input type="radio" name="solarexp" value="yes" id="solarexpyes"<?if (isset($_POST['solarexp']) && $_POST['solarexp'] != "no") echo "checked=\"checked\""?> onclick="check_toggle('yes')" />
			 Yes
			</td>
		       </tr>
		       <tr>
			<td>
			 <input type="radio" name="solarexp" value="no" id="solarexpno"<?if (isset($_POST['solarexp']) && $_POST['solarexp'] == "no") echo " checked=\"checked\""?> onclick="check_toggle('no')" />
			 No
			</td>
		       </tr>
		      </table>
		     </td>
		    </tr>
		    <tr>
		      <td width="40%"><font color="#ff0000" id="star1">*</font>If yes, what type of Solar Collectors have you used in your installations?</td>
		      <td width="60%">
		       <table width="200">
			<tr>
			 <td>
			  <input type="radio" name="collectortypes" value="evactubes" id="collectortypes_0"<?if (isset($_POST['collectortypes']) && $_POST['collectortypes'] == "evactubes") echo " checked=\"checked\""?> />
			  Evacuated Tube Collectors
			 </td>
			</tr>
			<tr>
			 <td>
			  <input type="radio" name="collectortypes" value="flatplates" id="collectortypes_1"<?if (isset($_POST['collectortypes']) &&  $_POST['collectortypes'] == "flatplates") echo " checked=\"checked\""?> />
			  Flat Plate Collectors
			 </td>
			</tr>
			<tr>
			 <td>
			  <input type="radio" name="collectortypes" value="both" id="collectortypes_2"<?if (isset($_POST['collectortypes']) && $_POST['collectortypes'] == "both") echo " checked=\"checked\""?> />
			  Both
			 </td>
			</tr>
		       </table>
		      </td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000" id="star2">*</font>If yes, please indicate the quantity of each type of Solar Hot Water System you have installed:</td>
		     <td width="60%">&nbsp;</td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000" id="star3">*</font>Number of Domestic Solar Hot Water</td>
		     <td width="60%"><input name="qtydomestic" type="text" id="qtydomestic" size="40" value="<? if(isset($_POST['qtydomestic'])){echo $_POST['qtydomestic'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000" id="star4">*</font>Number of Radiant/Space Heating/Cooling</td>
		     <td width="60%"><input name="qtyheating" type="text" id="qtyheating" size="40" value="<? if(isset($_POST['qtyheating'])){echo $_POST['qtyheating'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000" id="star5">*</font>Number of Pool &amp; Spa Heating</td>
		     <td width="60%"><input name="qtypool" type="text" id="qtypool" size="40" value="<? if(isset($_POST['qtypool'])){echo $_POST['qtypool'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000" id="star6">*</font>If yes, how many years have you been installing Solar Hot Water Systems?</td>
		     <td width="60%">
		      <select name="shwexpyrs" id="shwexpyrs">
		       <option value="">Please Select One</option>
		       <option value="0to1"<?if (isset($_POST['shwexpyrs']) && $_POST['shwexpyrs'] == "0to1") echo " selected=\"selected\""?>>0 - 1 Years</option>
		       <option value="1to3"<?if (isset($_POST['shwexpyrs']) && $_POST['shwexpyrs'] == "1to3") echo " selected=\"selected\""?>>1 - 3 Years</option>
		       <option value="4to6"<?if (isset($_POST['shwexpyrs']) && $_POST['shwexpyrs'] == "4to6") echo " selected=\"selected\""?>>4 - 6 Years</option>
		       <option value="6to8"<?if (isset($_POST['shwexpyrs']) && $_POST['shwexpyrs'] == "6to8") echo " selected=\"selected\""?>>6 - 8 Years</option>
		       <option value="8to10"<?if (isset($_POST['shwexpyrs']) && $_POST['shwexpyrs'] == "8to10") echo " selected=\"selected\""?>>8 - 10 Years</option>
		       <option value="10plus"<?if (isset($_POST['shwexpyrs']) && $_POST['shwexpyrs'] == "10plus") echo " selected=\"selected\""?>>10 Plus Years</option>
		      </select>
		     </td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000" id="star7">*</font>If yes, what percentage of your current workload does Solar Hot Water account for?</td>
		     <td width="60%"><input name="shwpercent" type="text" id="shwpercent" size="40" value="<? if(isset($_POST['shwpercent'])){echo $_POST['shwpercent'];}?>" /></td>
		    </tr>
		    <tr>
		     <td width="40%"><font color="#ff0000">*</font>In what area(s) are you looking to provide sales, installation and service? If you are covering a state, or more, please list the states - if you are covering less than a state, please list the zip codes, or counties that you are looking to cover.</td>
		     <td width="60%">
		     <textarea name="coverarea" cols="40" rows="5" wrap="physical" id="coverarea"><? if(isset($_POST['coverarea'])){echo $_POST['coverarea'];}?></textarea>
		     </td>
		    </tr>
		    <tr>
		     <td>Please indicate your first year expected sales goals broken down by quater:</td>
		     <td>
		      <table width="100%" border="0" cellspacing="0" cellpadding="0">
		       <tr>
			<td width="25%" height="30"><div align="center"><font color="#ff0000">*</font><strong>Q1</strong></div></td>
			<td width="25%" height="30"><div align="center"><font color="#ff0000">*</font><strong>Q2</strong></div></td>
			<td width="25%" height="30"><div align="center"><font color="#ff0000">*</font><strong>Q3</strong></div></td>
			<td width="25%" height="30"><div align="center"><font color="#ff0000">*</font><strong>Q4</strong></div></td>
		       </tr>
		       <tr>
			<td width="25%" height="30" valign="middle">
			 <div align="center">
			 <input name="q1sales" type="text" id="q1sales" size="10" value="<? if(isset($_POST['q1sales'])){echo $_POST['q1sales'];}?>" />
			 </div>
			</td>
			<td width="25%" height="30" valign="middle">
			 <div align="center">
			 <input name="q2sales" type="text" id="q2sales" size="10" value="<? if(isset($_POST['q2sales'])){echo $_POST['q2sales'];}?>" />
			 </div>
			</td>
			<td width="25%" height="30" valign="middle">
			 <div align="center">
			 <input name="q3sales" type="text" id="q3sales" size="10" value="<?if(isset($_POST['q3sales'])){echo $_POST['q3sales'];}?>" />
			 </div>
			</td>
			<td width="25%" height="30" valign="middle">
			 <div align="center">
			 <input name="q4sales" type="text" id="q4sales" size="10" value="<?if(isset($_POST['q4sales'])){echo $_POST['q4sales'];}?>" />
			 </div>
			</td>
		       </tr>
		      </table>
		     </td>
		    </tr>
		    <tr>
		     <td><strong>Customer &amp; Trade References:</strong></td>
		     <td>&nbsp;</td>
		    </tr>
		    <tr>
		     <td>Please List 3 Customers that you have provided plumbing, heating or other installation services in the last 3 years?</td>
		     <td>&nbsp;</td>
		    </tr>
		    <tr>
		     <td><strong>Customer 1:</strong></td>
		     <td>&nbsp;</td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Name:</td>
		     <td><input name="c1name" type="text" id="c1name" size="40" value="<? if(isset($_POST['c1name'])){echo $_POST['c1name'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Phone:</td>
		     <td><input name="c1phone" type="text" id="c1phone" size="40" value="<? if(isset($_POST['c1phone'])){echo $_POST['c1phone'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>System/Install Type:</td>
		     <td><textarea name="c1type" cols="40" rows="2" id="c1type"><? if(isset($_POST['c1type'])){echo $_POST['c1type'];}?></textarea></td>
		    </tr>
		    <tr>
		     <td><strong>Customer 2:</strong></td>
		     <td>&nbsp;</td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Name:</td>
		     <td><input name="c2name" type="text" id="c2name" size="40" value="<? if(isset($_POST['c2name'])){echo $_POST['c2name'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Phone:</td>
		     <td><input name="c2phone" type="text" id="c2phone" size="40" value="<? if(isset($_POST['c2phone'])){$_POST['c2phone'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>System/Install Type:</td>
		     <td><textarea name="c2type" cols="40" rows="2" id="c2type"><? if(isset($_POST['c2type'])){$_POST['c2type'];}?></textarea></td>
		    </tr>
		    <tr>
		     <td><strong>Customer 3:</strong></td>
		     <td>&nbsp;</td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Name:</td>
		     <td><input name="c3name" type="text" id="c3name" size="40" value="<? if(isset($_POST['c3name'])){echo $_POST['c3name'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Phone:</td>
		     <td><input name="c3phone" type="text" id="c3phone" size="40" value="<? if(isset($_POST['c3phone'])){echo $_POST['c3phone'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>System/Install Type:</td>
		     <td><textarea name="c3type" cols="40" rows="2" id="c3type"><? if(isset($_POST['c3type'])){echo $_POST['c3type'];}?></textarea></td>
		    </tr>
		    <tr>
		     <td>Please list 3 current (or recent) trade references that you do business with. Can be a plumbing supplier, hardware supplier, banking/finance provider, etc.</td>
		     <td>&nbsp;</td>
		    </tr>
		    <tr>
		     <td><strong>Trade Reference 1:</strong></td>
		     <td>&nbsp;</td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Company Name:</td>
		     <td><input name="tr1company" type="text" id="tr1company" size="40" value="<? if(isset($_POST['tr1company'])){echo $_POST['tr1company'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Contact Person:</td>
		     <td><input name="tr1contact" type="text" id="tr1contact" size="40" value="<? if(isset($_POST['tr1contact'])){echo $_POST['tr1contact'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Phone Number:</td>
		     <td><input name="tr1phone" type="text" id="tr1phone" size="40" value="<? if(isset($_POST['tr1phone'])){echo $_POST['tr1phone'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><strong>Trade Reference 2:</strong></td>
		     <td>&nbsp;</td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Company Name:</td>
		     <td><input name="tr2company" type="text" id="tr2company" size="40" value="<?if(isset($_POST['tr2company'])){echo $_POST['tr2company'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Contact Person:</td>
		     <td><input name="tr2contact" type="text" id="tr2contact" size="40" value="<? if(isset($_POST['tr2contact'])){echo $_POST['tr2contact'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Phone Number:</td>
		     <td><input name="tr2phone" type="text" id="tr2phone" size="40" value="<? if(isset($_POST['tr2phone'])){echo $_POST['tr2phone'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><strong>Trade Reference 3:</strong></td>
		     <td>&nbsp;</td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Company Name:</td>
		     <td><input name="tr3company" type="text" id="tr3company" size="40" value="<? if(isset($_POST['tr3company'])){echo $_POST['tr3company'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Contact Person:</td>
		     <td><input name="tr3contact" type="text" id="tr3contact" size="40" value="<? if(isset($_POST['tr3contact'])) {echo $_POST['tr3contact'];}?>" /></td>
		    </tr>
		    <tr>
		     <td><font color="#ff0000">*</font>Phone Number:</td>
		     <td><input name="tr3phone" type="text" id="tr3phone" size="40" value="<? if(isset($_POST['tr3phone'])){echo $_POST['tr3phone'];}?>" /></td>
		    </tr>
		    <tr>
		     <td colspan="2" style="text-align:center;">
		     <?
			    
			    $form_captcha_part = $captcha->display_form_part('text_notvalid') . '<br/>' . 
						 $captcha->display_form_part('image') . '<br/><br/>' . 
						 $captcha->display_form_part('input') . '<br/>' . 
						 $captcha->display_form_part('text') . '<br/><br/>' . 
						 $captcha->display_form_part('refresh_text') . ' ' . 
						 $captcha->display_form_part('refresh_button') . ''; 
						 echo $form_captcha_part; 
			   
		     ?>
		     </td>
		    </tr>
		    <tr>
		     <td>&nbsp;</td>
		     <td>&nbsp;</td>
		    </tr>
		    <tr>
		     <td>&nbsp;</td>
		     <td>
		      <input type="submit" name="submit" id="submit" value="Submit Application" />
		      <input type="reset" name="clear" id="clear" value="Clear Application" />
		     </td>
		    </tr>
		  </table>
		</form>
		<script type="text/javascript"><!-- check_toggle('<?=$_POST['solarexp']?>') //--></script>
		<?	
		///////////////////////////////////
		// End edits made by Sonny Michaud
		///////////////////////////////////
    break;
    }
function check_form() {
	global $form_values;
	global $username;
	$error_array = array();
	if (isset($_POST['apptype']) && $_POST['apptype'] == "") $error_array[] = "Application Type";
	if (isset($_POST['firstname']) && $_POST['firstname'] == "") $error_array[] = "First Name";
	if (isset($_POST['lastname']) && $_POST['lastname'] == "") $error_array[] = "Last Name";
	if (isset($_POST['companyname']) && $_POST['companyname'] == "") $error_array[] = "Company Name (DBA)";
	if (isset($_POST['taxid']) && $_POST['taxid'] == "") $error_array[] = "Tax ID Number";
	if (isset($_POST['address1']) && $_POST['address1'] == "") $error_array[] = "Address 1";
	//if ($_POST['address2'] == "") $error_array[] = "Address 2";
	if (isset($_POST['city']) && $_POST['city'] == "") $error_array[] = "City";
	if (isset($_POST['state']) && $_POST['state'] == "") $error_array[] = "State";
	if (isset($_POST['zip']) && $_POST['zip'] == "") $error_arrayp[] = "Zip Code";
	if (isset($_POST['country']) && $_POST['country'] == "") $error_array[] = "Country";
	if (isset($_POST['phone']) && $_POST['phone'] == "") $error_array[] = "Phone Number";
	if (isset($_POST['fax']) && $_POST['fax'] == "") $error_array[] = "Fax Number";
	if (isset($_POST['email']) && $_POST['email'] == "") $error_array[] = "Email Address";
	//if ($_POST['website'] == "") $error_array[] = "Website";
	if (isset($_POST['primefocus']) && $_POST['primefocus'] == "") $error_array[] = "Primary Business Focus";
	if (isset($_POST['yrsinbusiness']) && $_POST['yrsinbusiness'] == "") $error_array[] = "Number of Years in Business";
	if (isset($_POST['solarexp']) && $_POST['solarexp'] == "") $error_array[] = "Have you ever installed Solar Hot Water Collectors or Systems before?";
	elseif (isset($_POST['solarexp']) && $_POST['solarexp'] == "yes") {
		if (isset($_POST['collectortypes']) && $_POST['collectortypes'] == "") $error_array[] = "What type of Solar Collectors have you used in your installations?";
		if (isset($_POST['qtydomestic']) && $_POST['qtydomestic'] == "") $error_array[] = "Number of Domestic Solar Hot Water";
		if (isset($_POST['qtyheating']) && $_POST['qtyheating'] == "") $error_array[] = "Number of Radiant/Space Heating/Cooling";
		if (isset($_POST['qtypool']) && $_POST['qtypool'] == "") $error_array[] = "Number of Pool &amp; Spa Heating";
		if (isset($_POST['shwexpyrs']) && $_POST['shwexpyrs'] == "") $error_array[] = "How many years have you been installing Solar Hot Water Systems?";
		if (isset($_POST['shwpercent']) && $_POST['shwpercent'] == "") $error_array[] = "What percentage of your current workload does Solar Hot Water account for?";
	}
	if (isset($_POST['coverarea']) && $_POST['coverarea'] == "") $error_array[] = "In what area(s) are you looking to provide sales, installation and service?";
	if (isset($_POST['q1sales']) && $_POST['q1sales'] == "") $error_array[] = "Expected sales goal for Q1";
	if (isset($_POST['q2sales']) && $_POST['q2sales'] == "") $error_array[] = "Expected sales goal for Q2";
	if (isset($_POST['q3sales']) && $_POST['q3sales'] == "") $error_array[] = "Expected sales goal for Q3";
	if (isset($_POST['q4sales']) && $_POST['q4sales'] == "") $error_array[] = "Expected sales goal for Q4";
	if (isset($_POST['c1name']) && $_POST['c1name'] == "") $error_array[] =  "Customer 1 Name";
	if (isset($_POST['c1phone']) && $_POST['c1phone'] == "") $error_array[] = "Customer 1 Phone";
	if (isset($_POST['c1type']) && $_POST['c1type'] == "") $error_array[] = "Customer 1 System/Install Type";
	if (isset($_POST['c2name']) && $_POST['c2name'] == "") $error_array[] =  "Customer 2 Name";
	if (isset($_POST['c2phone']) && $_POST['c2phone'] == "") $error_array[] = "Customer 2 Phone";
	if (isset($_POST['c2type']) && $_POST['c2type'] == "") $error_array[] = "Customer 2 System/Install Type";
	if (isset($_POST['c3name']) && $_POST['c3name'] == "") $error_array[] =  "Customer 3 Name";
	if (isset($_POST['c3phone']) && $_POST['c3phone'] == "") $error_array[] = "Customer 3 Phone";
	if (isset($_POST['c3type']) && $_POST['c3type'] == "") $error_array[] = "Customer 3 System/Install Type";
	if (isset($_POST['tr1company']) && $_POST['tr1company'] == "") $error_array[] = "Trade Reference 1 Company";
	if (isset($_POST['tr1contact']) && $_POST['tr1contact'] == "") $error_array[] = "Trade Reference 1 Contact Person";
	if (isset($_POST['tr1phone']) && $_POST['tr1phone'] == "") $error_array[] = "Trade Reference 1 Phone Number";
	if (isset($_POST['tr2company']) && $_POST['tr2company'] == "") $error_array[] = "Trade Reference 2 Company";
	if (isset($_POST['tr2contact']) && $_POST['tr2contact'] == "") $error_array[] = "Trade Reference 2 Contact Person";
	if (isset($_POST['tr2phone']) && $_POST['tr2phone'] == "") $error_array[] = "Trade Reference 2 Phone Number";
	if (isset($_POST['tr3company']) && $_POST['tr3company'] == "") $error_array[] = "Trade Reference 3 Company";
	if (isset($_POST['tr3contact']) && $_POST['tr3contact'] == "") $error_array[] = "Trade Reference 3 Contact Person";
	if (isset($_POST['tr3phone']) && $_POST['tr3phone'] == "") $error_array[] = "Trade Reference 3 Phone Number";
	$username = "d".$_POST['firstname'].$_POST['lastname'].rand(0,9).rand(0,9);
	$check_login = mysql_query("SELECT login FROM xcart_customers WHERE login='".$username."'");
	if (mysql_num_rows($check_login) > 0) $error_array[] = "Username ".$_POST['username']." is already taken.  Please select a new one.";

	foreach($_POST as $key) { if(isset($_POST[$key])){ $_POST[$key]= mysql_real_escape_string($_POST[$key]);}}

	if (count($error_array) > 0) {
		echo "<font color=\"#ff0000\">";
		echo "There is an error in the form\n<br />\n";
		echo "The following items are either not filled in or are improper values:\n<br />\n<br />\n";
		foreach ($error_array as $value) echo $value."\n<br />\n";
		echo "</font>";
		return false;
	}
	else {
		$app_type = ($_POST['apptype'] == "d") ? "Dealer and Installer" : "Installer Only";
		$form_values = array("Application Type" => $app_type, "First Name" => $_POST['firstname'], "Last Name" => $_POST['lastname'],
			"Company Name (DBA)" => $_POST['companyname'], 
			"Tax ID Number" => $_POST['taxid'], 
			"Address 1" => $_POST['address1'], 
			"Address 2" => $_POST['address2'],
			"City" => $_POST['city'], "State" => $_POST['state'], "Zip Code" => $_POST['zip'], "Country" => $_POST['country'], "Phone Number" => $_POST['phone'],
			"Fax Number" => $_POST['fax'], "Email Address" => $_POST['email'], "Website" => $_POST['website'], "Primary Business Focus" => $_POST['primefocus'],
			"Number of Years in Business" => $_POST['yrsinbusiness'], "Ever installed SHW Collectors or Systems?" => $_POST['solarexp']);
		if (isset($_POST['solarexp']) && $_POST['solarexp']=="yes") $form_values = array_merge($form_values, 
			array("What type of Solar Collectors have you used in your installations?" => $_POST['collectortypes'],
			"Number of Domestic Solar Hot Water" => $_POST['qtydomestic'],
			"Number of Radiant/Space Heating/Cooling" => $_POST['qtyheating'],
			"Number of Pool &amp; Spa Heating" => $_POST['qtypool'],
			"How many years have you been installing Solar Hot Water Systems?" => $_POST['shwexpyrs'],
			"What percentage of your current workload does Solar Hot Water account for?" => $_POST['shwpercent']));
		$form_values = array_merge($form_values, array("In what area(s) are you looking to provide sales, installation and service?" => $_POST['coverarea'],
			"Expected sales goal for Q1" => $_POST['q1sales'], "Expected sales goal for Q2" => $_POST['q2sales'], "Expected sales goal for Q3" => $_POST['q3sales'],
			"Expected sales goal for Q4" => $_POST['q4sales'], "Customer 1 Name" => $_POST['c1name'], "Customer 1 Phone" => $_POST['c1phone'],
			"Customer 1 System/Install Type" => $_POST['c1type'], "Customer 2 Name" => $_POST['c2name'], "Customer 2 Phone" => $_POST['c2phone'],
			"Customer 2 System/Install Type" => $_POST['c2type'], "Customer 3 Name" => $_POST['c3name'], "Customer 3 Phone" => $_POST['c3phone'],
			"Customer 3 System/Install Type" => $_POST['c3type'], "Trade Reference 1 Company" => $_POST['tr1company'],
			"Trade Reference 1 Contact Person" => $_POST['tr1contact'], "Trade Reference 1 Phone Number" => $_POST['tr1phone'],
			"Trade Reference 2 Company" => $_POST['tr2company'], "Trade Reference 2 Contact Person" => $_POST['tr2contact'],
			"Trade Reference 2 Phone Number" => $_POST['tr2phone'], "Trade Reference 3 Company" => $_POST['tr3company'],
			"Trade Reference 3 Contact Person" => $_POST['tr3contact'], "Trade Reference 3 Phone Number" => $_POST['tr3phone']));
		return true;
	}
}

function send_form() {
	
	global $form_values;
	global $username;
	$body="";
	foreach ($form_values as $key => $value) $body .= $key.":  ".$value."\n<br/>";
	$body_support = "A new application for becoming a SunMaxx dealer has been submitted.  To review it, please follow <a href='http://www.siliconsolar.com/shop/admin/user_modify.php?user=".$username."&usertype=C'>this link</a>.<br/>Below is a copy of the form submitted.<br/><br/>";
	$body_user = "<br/><br/>Thank you for submitting your application.  We will contact you as soon as we are able to process the application.  Below is a copy of the information you submitted.  Feel free to reply to this e-mail if you have any questions, concerns, or changes you would like to make to the text submitted.\n\nThank you for your patience and we look forward to serving you!<br/><br/>";
	$mail = mail($form_values['Email Address'], "SHW Dealer Application at SunMaxxSolar.com", $body_user.$body, "From: shw-dealer.support@siliconsolar.com");
	echo $form_values['Email Address'], " SHW Dealer Application at SunMaxxSolar.com", $body_user.$body, "From: shw-dealer.support@siliconsolar.com";
	mail("shw-dealer.support@siliconsolar.com", "SHW Dealer Application – SunMaxxSolar.com", $body_support.$body, "From: ".$form_values['Email Address']);
	($form_values['Address 2'] == "") ? $address = $form_values['Address 1'] : $address = $form_values['Address 1']."\n".$form_values['Address 2'];
	$type = ($_POST['apptype'] == "d") ? 7 : 13;
	
	if($_POST['solarexp']=='no'){$_POST['collectortypes']='';$_POST['qtydomestic']='';$_POST['qtyheating']='';$_POST['qtypool']='';$_POST['shwexpyrs']='';$_POST['shwpercent']='';}
	
	mysql_query("INSERT INTO xcart_customers (login, usertype, cust_type, firstname, lastname, b_address, b_city, b_state, b_zipcode, company,".
			" email, phone, fax, url, membershipid)
	VALUES ('$username', 'C', 'Pending Dealer', '$_POST[firstname]', '$_POST[lastname]', '$address', '$_POST[city]',
		'$_POST[state]', '$_POST[zip]', '$_POST[companyname]', '$_POST[email]', '$_POST[phone]', '$_POST[fax]', '$_POST[website]', 17)") or die(mysql_error());
	mysql_query("INSERT INTO xcart_wholesalers (username, apptype, taxid, primary_focus, years_in_business, experience, collector_types, qty_domestic, qty_heating, qty_pool,
		exp_years, shw_percent, coverage_area, expected_sales_q1, expected_sales_q2, expected_sales_q3, expected_sales_q4, cust_1_name, cust_1_phone, cust_1_type,
		cust_2_name, cust_2_phone, cust_2_type, cust_3_name, cust_3_phone, cust_3_type, trade_ref_1_company, trade_ref_1_contact, trade_ref_1_phone, trade_ref_2_company,
		trade_ref_2_contact, trade_ref_2_phone, trade_ref_3_company, trade_ref_3_contact, trade_ref_3_phone)
	VALUES ('$username', '$_POST[apptype]', '$_POST[taxid]', '$_POST[primefocus]', '$_POST[yrsinbusiness]', '$_POST[solarexp]', '$_POST[collectortypes]', '$_POST[qtydomestic]',
		'$_POST[qtyheating]', '$_POST[qtypool]', '$_POST[shwexpyrs]', '$_POST[shwpercent]', '$_POST[coverarea]', '$_POST[q1sales]', '$_POST[q2sales]', '$_POST[q3sales]',
		'$_POST[q4sales]', '$_POST[c1name]', '$_POST[c1phone]', '$_POST[c1type]', '$_POST[c2name]','$_POST[c2phone]', '$_POST[c2type]', '$_POST[c3name]', '$_POST[c3phone]',
		'$_POST[c3type]', '$_POST[tr1company]', '$_POST[tr1contact]', '$_POST[tr1phone]', '$_POST[tr2company]', '$_POST[tr2contact]', '$_POST[tr2phone]',
		'$_POST[tr3company]', '$_POST[tr3contact]', '$_POST[tr3phone]')") or die(mysql_error());
	
	if($mail === true) 
		echo "<br/><br/>Thank for your application.  Our Dealer Development Team will process your application and contact you soon."; 
	else 
		echo 'Internal Server Error. Please contact the administrator';
	
}

?>

		</div><!-- #content -->
	</div><!-- #container -->

<?php include ('wp-content/themes/SunMaxxSolar/footer-no-wp.php'); ?>

</div><!-- #wrapper .hfeed -->

</body>
</html>